#!/usr/bin/python

from pandac.PandaModules import *
import random

from globals import *

class AudioMgr(object):

    # load sounds
    sounds = {
    'pewpew' : loader.loadSfx(DATAPATH+'/audio/pewpew.ogg'),
##    'dieSounds' : [
##        loader.loadSfx(DATAPATH+'audio/die-1.ogg'),
##        loader.loadSfx(DATAPATH+'audio/die-2.ogg'),
##        loader.loadSfx(DATAPATH+'audio/die-3.ogg'),
##    ],

    'boomSounds' : [
        loader.loadSfx(DATAPATH+'audio/boom1.ogg'),
        loader.loadSfx(DATAPATH+'audio/boom2_electric_boogaloo.ogg'),
        loader.loadSfx(DATAPATH+'audio/boom3.ogg'),
    ],

##    'ROBO-SOUNDS' : [
##        loader.loadSfx(DATAPATH+'audio/arg-1.ogg'),
##        loader.loadSfx(DATAPATH+'audio/arg-2.ogg'),
##        loader.loadSfx(DATAPATH+'audio/arg-3.ogg'),
##    ],
##    'gameover' : loader.loadSfx(DATAPATH+'audio/gameover.ogg'),
##    'music' : {
##        'game' : loader.loadSfx(DATAPATH+'audio/game.ogg'),
##    },
    }

    def playRandomSound(_, category):
        rand_num = random.randint(0,len(_.sounds[category])-1)
        _.sounds[category][rand_num].play()

    def play(_, sfxname):
        _.sounds[sfxname].play()

    def playMusic(_, trackname, volume=1.0):
        track =_.sounds['music'][trackname]
        track.setVolume(volume)
        track.setLoop(True)
        track.play()

audio = AudioMgr()


